﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Mooc
{
    public partial class Login : Form
    {
        public Login(Home home)
        {
            InitializeComponent();
            this.home = home;
        }

        Home home;

        SqlDao sqlDao = new SqlDao();

        private void sure_Click(object sender, EventArgs e)
        {
            if (s.Checked)
            {
                Stu stu = sqlDao.stuLogin(id.Text, pass.Text);
                if (stu.S_id != "")
                {
                    home.openForm(new StuApp(home, stu));
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }
            else if (t.Checked)
            {

                Tea tea = sqlDao.teaLogin(id.Text, pass.Text);
                if (tea.T_id != "")
                {
                    home.openForm(new TeaApp(home, tea));
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }
            else if (i.Checked)
            {
                Edu edu = sqlDao.issLogin(id.Text, pass.Text);
                if (edu.E_id != "")
                {
                    home.openForm(new EduApp(home, edu));
                }
                else
                {
                    MessageBox.Show("账号或密码错误...");
                }
            }
        }
    }
}
